package com.ease.util {

   import flash.utils.ByteArray;
   import mx.utils.SHA256;

   /**
    * An utility class to let you easily generate hashcodes for objects.
    */
   public class HashUtil {

      /**
       * Creates a SHA256 hashcode for the supplied <code>object</code>.
       *
       * @param value
       *    The object for which a hashcode is needed.
       *
       * The object is first written in a <code>ByteArray</code> stream
       * in AMF serialized format and then the hashcode of the <code>ByteArray</code>
       * is computed.
       *
       * @see mx.utils.SHA256
       */
      public static function toSHA256(value:Object):String {
         var bytes:ByteArray = new ByteArray();
         bytes.writeObject(value);
         return SHA256.computeDigest(bytes);
      }

   } // class
} // package
